fix: add safety boundaries to diagnostic output#806
Merged
Conversation
- Redact sensitive headers (Authorization, Cookie, etc.) from network requests - Redact sensitive URL query parameters (token, key, secret, etc.) - Cap individual fields: snapshot (100K chars), adapter source (50K chars), network requests (50 entries, 4K body each), stack trace (5K chars) - Enforce 256KB total output budget with graceful degradation: drops snapshot first, then page state entirely - Export truncate/redactUrl helpers for testing
Addresses review feedback: snapshot, consoleErrors, error message/hint/stack could contain inline secrets (Bearer tokens, JWTs, cookie values, token=value patterns). All string channels now pass through redactText() before emission. - Add redactText() with patterns for Bearer tokens, JWTs, cookie values, and inline key=value secrets - Apply redactText to: error.message, error.hint, error.stack, page.snapshot, page.consoleErrors - Add 6 new test cases for redactText and error message redaction
Fixes #808 items 1 and 3: 1. adapter.source was missing for all command types because buildRepairContext only checked cmd._modulePath (set only for manifest lazy-loaded TS). Now resolveAdapterSourcePath() checks cmd.source first, skips manifest: pseudo-paths, and maps dist/clis/*.js back to source clis/*.ts. 3. collectPageState() had no timeout — a hung CDP connection would block error propagation indefinitely. Now wrapped with 5s Promise.race timeout, falling back to emitting diagnostic without page state.
YAML commands inlined in the manifest previously lost their original file path, causing resolveAdapterSourcePath() to return undefined. Add sourceFile field to ManifestEntry so discovery can reconstruct the editable source path for both YAML and TS commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses the "Diagnostic / self-repair 还没有安全边界" concern — prevents PII, auth tokens, and private API responses from leaking into diagnostic output consumed by AI agents.
Test plan